package main

import (
	"wowCoupon.com/cache"
	"wowCoupon.com/engine/monitor"
	"wowCoupon.com/engine/statusMachine"
	"wowCoupon.com/models"
	"wowCoupon.com/pkg/flow"
	businessServer "wowCoupon.com/rpcserver/business/server"
	customerServer "wowCoupon.com/rpcserver/customer/server"
	"wowCoupon.com/setting"
)

func main() {
	//Init settings
	setting.Setup()

	// Init mysql
	models.Setup()

	// Init Redis
	cache.SetUp()

	// Init flow
	flow.Setup()

	//Run the monitor
	e := monitor.NewMonitor()
	go e.Serve()

	// Run StatusMachine
	go statusMachine.CycleCheckCouponValidity()

	//Run the Rpc business server
	go businessServer.Serve()

	//Run the Rpc customer server
	customerServer.Serve()
}
